package cn.kgc.util;

import cn.kgc.dao.login.loginDao;
import cn.kgc.pojo.User;
import cn.kgc.service.login.loginService;
import cn.kgc.service.login.loginServiceImpl;
import cn.kgc.websocket.IndexWebSocket;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Controller;

import javax.annotation.Resource;
import javax.jws.WebService;
import java.util.ArrayList;
import java.util.List;

public class UserUtil {

    private static List<User> list = new ArrayList<User>();


    static {


        list.add(User.builder().id(1).username("admin").build());
        list.add(User.builder().id(2).username("zhangsan").build());
        list.add(User.builder().id(3).username("dapiaoliang").build());
        list.add(User.builder().id(4).username("lisi").build());
        list.add(User.builder().id(5).username("meinv01").build());
        list.add(User.builder().id(6).username("meinv02").build());
        list.add(User.builder().id(7).username("meinv03").build());
        list.add(User.builder().id(8).username("admin123").build());
        list.add(User.builder().id(9).username("admin1").build());
        list.add(User.builder().id(12).username("aaa").build());
        list.add(User.builder().id(13).username("qqq").build());
        list.add(User.builder().id(14).username("zhangsans11").build());
        list.add(User.builder().id(22).username("asd").build());
        System.out.println("users ============================================== ");
    }

    public static List<User> getUser() {
        return list;
    }

    public static User findById(Integer id) {
        return list.stream().filter(e -> e.getId() == id.intValue()).findFirst().orElse(null);
    }

    public static String getUsername(Integer id) {
        User user = findById(id);
        if (user == null) {
            return "null";
        }
        return user.getUsername();
    }
}
